<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('员工排班列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<form id="formFile" method="post" action="##"
			  class="report_form" target="_blank">
			<div class="form-group" title="Upload File">
					<label class="col-sm-3 control-label">排班Excel：</label>
					<input class="import-btn" type="file" accept=".xls,.xlsx">
			</div>
		</form>
	</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
	$(function () {
		$('.import-btn').change(function () {
			const formData = new FormData(),
					name = $(this).val();
			formData.append('file', $(this)[0].files[0])
			// 此处可传入多个参数
			formData.append('name', name)
			$.ajax({
				url: "/paiban/paibanTest/excel2Import",
				type: 'post',
				async: false,
				data: formData,
				// 告诉jQuery不要去处理发送的数据
				processData: false,
				// 告诉jQuery不要去设置Content-Type请求头
				contentType: false,
				beforeSend: function () {
					console.log('正在进行，请稍候')
				},
				success: function (data) {
					if (data.code === 0){
						alert("导入成功")
					}
				}
			})
		})
	});
</script>
</body>
</html>